package com.kexun.servlet.admin;

import com.alibaba.fastjson.JSON;
import com.kexun.pojo.Course;
import com.kexun.service.AdmService;
import com.kexun.service.impl.AdmServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/ServletupCouse")
public class ServletupCouse extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        String couName = request.getParameter("couName");


        AdmService as = new AdmServiceImpl();
        Course cou = as.findCouse(couName);
        String s = JSON.toJSONString(cou);

        if(s!=null){
            response.getWriter().print(s);
//            request.getRequestDispatcher("admin/updCourse.html").forward(request,response);
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
